﻿<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
<title>报表设置</title>
<style>
	.tabCaption{font-size:9pt;cursor:default;padding-left:5;padding-top:2;padding-right:5;padding-bottom:0;width:100%;height:100%;}
	td{font-size:9pt}
</style>
<script language=javascript>
	var tabCount=0;
	var oldSelectedTab=new Array();
	var currentSelectedTab=null;
	var currentSelectColor="#000000";			//当前选择的颜色
	var captionText="";
	var captionColor="#000000";		//报表标题颜色
	var captionFont="";
	var captionFontBold=true;
	var captionFontSize="20";
	
	var titleFont="";
	var titleFontBold=true;
	var titleFontSize="20";
	var titleColor="#000000";		//表头颜色
	var titleAuthor="";
	var titleDate="";
	
	var bodyColor="#000000";
	var bodyOutBorderColor="#000000";
	var bodyInBorderColor="#000000";
	
	var DataReadInterval;
	var RetryTimesCount;
	
	var AlwaysPrintHead=false;		//是否总是在每页都打印列头
	var HeadAlign="left";			//列头对齐方式
	
	function CreateTab(title,id)
	{
		tabMode=document.all("TabMode").childNodes[0].cloneNode(true);
		var tabTitle=tabMode.rows[2].cells[2].childNodes[0];
		tabTitle.innerText=title;
		tabTitle.setAttribute("tabID",id);
		tabTitle.id="tab_"+id;
		maintable=document.all("MainTable");
		var newcell;
		if(maintable.rows[0].cells.length==1)
			newcell=maintable.rows[0].insertCell(0);
		else
			newcell=maintable.rows[0].insertCell(maintable.rows[0].cells.length-1);
		newcell.innerHTML="<table  cellspacing=0 cellpadding=0 bgcolor=menu>"+tabMode.innerHTML+"</table>";
		
	}
	function CreateTabs()
	{
		CreateTab("标题设置","tab0");
		CreateTab("表头设置","tab1");
		CreateTab("表体设置","tab2");
		CreateTab("选项","tab3");
	}
	function SelectTab(id)
	{
		document.all("tab_"+id).click();
	}
	function OnSelectTab(srcElement)
	{
		id=srcElement.getAttribute("tabID");
		if(document.getElementById(id)!=null)
		{
			document.all("tabContentArea").innerHTML=document.all(id).innerHTML;
		}
		if(oldSelectedTab.length>0)
		{
			oldSelectedTab[0].style.height=18;
			oldSelectedTab[1].style.backgroundColor="white";
		}
		srcElement.parentElement.style.height=20;
		table=srcElement.parentElement.parentElement.parentElement.parentElement;
		table.rows[3].cells[1].style.backgroundColor="menu";
		oldSelectedTab[0]=srcElement.parentElement;
		oldSelectedTab[1]=table.rows[3].cells[1];
		currentSelectedTab=srcElement;
	}
	function Initialize()
	{
		parentWin=window.dialogArguments;
		document.all("ReportTitle").value=captionText=parentWin.GetReportTitle();
		DataReadInterval=parentWin.printInterval/1000;
		document.all("printInterval").value=DataReadInterval;
		RetryTimesCount=document.all("RetryTimesCount").value=parentWin.RetryTimesCount;
		getSystemFonts();
		
		//加载初始变量值

		//标题初始化
		document.body.insertAdjacentHTML("beforeEnd","<span id=\"captionStylePreview\" style='"+parentWin.captionStyle+";display:none'></span>");
		tempStyle=document.all("captionStylePreview").style;
		document.all("txt_captionFontSize").value=captionFontSize=tempStyle.fontSize.replace("pt","");
		captionFont=tempStyle.fontFamily;
		if(tempStyle.fontWeight.toLowerCase()=="bold")
			captionFontBold=true;
		else
			captionFontBold=false;
		document.all("chk_captionFontBold").checked=captionFontBold;
		if(tempStyle.color!="")
			captionColor=tempStyle.color;
		document.all("captionColorPreview").style.backgroundColor=captionColor;
		SelectList(document.all("FontList0"),captionFont);
		
		//表头初始化
		document.body.insertAdjacentHTML("beforeEnd","<span id=\"titleStylePreview\" style='"+parentWin.titleStyle+";display:none'></span>");
		tempStyle=document.all("titleStylePreview").style;
		document.all("txt_titleFontSize").value=titleFontSize=tempStyle.fontSize.replace("pt","");
		titleFont=tempStyle.fontFamily;
		if(tempStyle.fontWeight.toLowerCase()=="bold")
			titleFontBold=true;
		else
			titleFontBold=false;
		document.all("chk_titleFontBold").checked=titleFontBold;
		if(tempStyle.color!="")
			titleColor=tempStyle.color;
		document.all("titleColorPreview").style.backgroundColor=titleColor;
		SelectList(document.all("FontList1"),titleFont);
		titleAuthor=document.all("Author").value=parentWin.Author;
		var date="";
		if(parentWin.ReportDate=="")
		{
			curdate=new Date();
			date=curdate.getYear()+" 年 "+(curdate.getMonth()+1)+" 月 "+curdate.getDate()+" 日 ";
		}
		else
			date=parentWin.ReportDate;
		titleDate=document.all("Date").value=date;
		
		//表体初始化
		document.body.insertAdjacentHTML("beforeEnd","<span id=\"bodyStylePreview\" style='"+parentWin.getBodyStyle()+";display:none'></span>");
		tempStyle=document.all("bodyStylePreview").style;
		if(tempStyle.borderColor!="")
			bodyOutBorderColor=tempStyle.borderColor;
		if(tempStyle.color!="")
			bodyColor=tempStyle.color;
		document.all("bodyColorPreview").style.backgroundColor=bodyColor;
		document.all("bodyOutBorderColorPreview").style.backgroundColor=bodyOutBorderColor;
		document.all("chk_AlwaysPrintHead").checked=AlwaysPrintHead=parentWin.AlwaysPrintHead;
		HeadAlign=parentWin.HeadAlign;
		SelectList(document.all("AlignList"),HeadAlign);
		
		SelectTab("tab0");
	}
	function OnOK()
	{
		parentWin=window.dialogArguments;
		parentWin.ReportTitle=captionText;
		parentWin.RetryTimesCount=RetryTimesCount;
		parentWin.printInterval=DataReadInterval*1000;
		
		//报表标题样式
		if(captionFontSize=="")
			captionFontSize="20";
		captionStyle="font-family:"+captionFont+";font-size:"+captionFontSize+"pt;color:"+captionColor+";";
		if(captionFontBold)
			captionStyle+="font-weight:bold;";
		parentWin.captionStyle=captionStyle;
		
		//报表表头信息
		parentWin.Author=titleAuthor;
		parentWin.ReportDate=titleDate;
		titleStyle="font-family:"+titleFont+";font-size:"+titleFontSize+"pt;color:"+titleColor+";";
		if(titleFontBold)
			titleStyle+="font-weight:bold;";
		parentWin.titleStyle=titleStyle;
		
		//报表正文样式
		parentWin.bodyColor=bodyColor;
		parentWin.bodyOutBorderColor=bodyOutBorderColor;
		parentWin.AlwaysPrintHead=AlwaysPrintHead;
		parentWin.HeadAlign=HeadAlign;
		window.close();
	}
	function OnCancel()
	{
		window.close();
	}
	
	function SelectList(select,text)
	{
		for(i=0;i<select.options.length;i++)
		{
			if(select.options[i].value==text)
			{
				select.selectedIndex=i;
				break;
			}
		}
	}
	//获取当前系统的字体
	function getSystemFonts()
	{
		var aOptions = document.all("FontList0").options;        
		var aOptions1 = document.all("FontList1").options;        
		for (i = 1;i < dlgHelper.fonts.count;i++)
		{        
			var oOption = document.createElement("OPTION");
			aOptions.add(oOption);        
			oOption.text =dlgHelper.fonts(i);
			oOption.value =dlgHelper.fonts(i);
			
			var oOption1 = document.createElement("OPTION");
			aOptions1.add(oOption1);        
			oOption1.text = dlgHelper.fonts(i);
			oOption1.value =dlgHelper.fonts(i);
		}
	}
	
	function getSystemColor()
	{
		var curColor;
		curColor=window.event.srcElement.parentElement.parentElement.cells[1].childNodes[0].style.backgroundColor;
		var oColor = dlgHelper.ChooseColorDlg(curColor).toString(16)
		oColor="#"+((oColor.length < 6)?"000000".substring(0,6-oColor.length):"")+oColor
		curRow=window.event.srcElement.parentElement.parentElement;
		curRow.cells[1].childNodes[0].style.backgroundColor=oColor;
		currentSelectColor=oColor;
	}
	function SetValue(varName,varValue,valueIsString)
	{
		if(valueIsString)
			script=varName+"='"+varValue+"'";
		else
			script=varName+"="+varValue;
		eval(script);
		if(window.event.srcElement.tagName=="INPUT")
		{
			controls=document.all(window.event.srcElement.id);
			switch(window.event.srcElement.getAttribute("type"))
			{
				case "text":
					controls[1].value=varValue;
					break;
				case "checkbox":
					controls[1].checked=varValue;
					break;
				case "button":
					if(window.event.srcElement.getAttribute("colorDialog")!=null)
					{
						var curRow=window.event.srcElement.parentElement.parentElement;
						controls=document.all(curRow.cells[1].childNodes[0].id);
						controls[1]	.style.backgroundColor=currentSelectColor;
					}
					break;
			}
		}
		else
		{
			controls=document.all(window.event.srcElement.id);
			SelectList(controls[1],varValue);
		}
	}
</script>
</head>
<body onload="CreateTabs();Initialize();" style="border:0" bgcolor=Menu topmargin=0 bottommargin=0 leftmargin=1 scroll=no>
<OBJECT ID=dlgHelper CLASSID="clsid:3050f819-98b5-11cf-bb82-00aa00bdce0b" WIDTH="0px" HEIGHT="0px" ></OBJECT>
<div ID="TabMode" style="display:none">
	<table cellspacing=0 cellpadding=0 bgcolor=menu>
	<tr>
		<td width=1 height=1></td><td width=1 height=1></td>
		<td bgcolor=white></td><td></td><td></td>
	</tr>
	<tr>
		<td width=1 height=1></td><td width=1 height=1 bgcolor=white></td>
		<td></td><td bgcolor=black></td><td></td>
	</tr>
	<tr>
		<td width=1 bgcolor=white></td><td width=1 height=1></td>
		<td height=18><span class=tabCaption onclick="OnSelectTab(this)" onselectstart="return false"></span></td><td width=1 bgcolor=gray></td>
		<td bgcolor=black width=1></td>
	</tr>
	<tr>
		<td bgcolor=white></td><td colspan=4 height=1 bgcolor=white></td>
	</tr>
</table>
</div>

<table width=100% bgcolor=menu>
	<tr>
		<td>
			<table cellpadding=0 cellspacing=0 onselectstart="return false" ID="MainTable">
				<tr height=20>
					<td style="border-bottom:1 white solid">
						<table cellspacing=0 cellpadding=0 width=135>
							<tr>
								<td height=1>
							</tr>
						</table>
					</td>
				</tr>
			</table>
			<div style="padding:10;width:100%;height:208;border-left:1 white solid;border-right:2 outset;border-bottom:2 outset">
				<span id=tabContentArea>
				</span>
			</div>
		</td>
	</tr>
</table>
<table width=100%>
	<tr>
		<td align=right><input type=button value="确　　定" onclick="OnOK()"><input type=button value="取　　消" onclick="OnCancel()"></td>
	</tr>
</table>
<div style="display:none" id="tabContent">
	<div id="tab0">
		报表标题：<input type=text  id="ReportTitle" onchange="SetValue('captionText',this.value,true)"  style="width:200px">
		<fieldset>
			<legend><font size=2>标题样式</font></legend>
			<table>
				<tr>
					<td>
						<table>
							<tr>
								<td>字体<select onchange="SetValue('captionFont',this.options[this.selectedIndex].value,true)" id="FontList0"></select></td>
							</tr>
							<tr>
								<td>
									<table>
										<tr>
											<td>颜色</td>
											<td><table width=40 height=20 id="captionColorPreview" style="BORDER-RIGHT: white thin groove; BORDER-TOP: buttonshadow thin groove; BORDER-LEFT: buttonshadow thin groove; BORDER-BOTTOM: white thin groove"><tr><td></td></tr></table></td>
											<td><input type=button value="..." onclick="getSystemColor();SetValue('captionColor',currentSelectColor,true)" colorDialog=true></td>
										</tr>
									</table>
								</td>
							</tr>
							<tr>
								<td>大小<input id="txt_captionFontSize" type=text value="20" style="width:40px"; onchange="SetValue('captionFontSize',this.value,true)">pt&nbsp;&nbsp;粗体<input type=checkbox id="chk_captionFontBold" onclick="SetValue('captionFontBold',this.checked,false)" checked=true></td>
							</tr>
						</table>
					</td>
				</tr>
			</table>
		</fieldset>
	</div>
	<div id="tab1">
		<table>
			<tr>
				<td>制表人：</td><td><input type=text id="Author" onchange="SetValue('titleAuthor',this.value,true)" style="width:200px"></td>
			</tr>
			<tr>
				<td>制表日期：</td><td><input type=text id="Date" onchange="SetValue('titleDate',this.value,true)" style="width:200px"></td>
			</tr>
		</table>
		<fieldset>
			<legend><font size=2>表头样式</font></legend>
			<table>
				<tr>
					<td>
						<table>
							<tr>
								<td>字体<select onchange="SetValue('titleFont',this.options[this.selectedIndex].value,true)" id="FontList1"></select></td>
							</tr>
							<tr>
								<td>
									<table>
										<tr>
											<td>颜色</td>
											<td><table width=40 height=20   id="titleColorPreview" style="BORDER-RIGHT: white thin groove; BORDER-TOP: buttonshadow thin groove; BORDER-LEFT: buttonshadow thin groove; BORDER-BOTTOM: white thin groove"><tr><td></td></tr></table></td>
											<td><input type=button value="..." onclick="getSystemColor();SetValue('titleColor',currentSelectColor,true)" colorDialog=true></td>
										</tr>
									</table>
								</td>
							</tr>
							<tr>
								<td>大小<input  id="txt_titleFontSize" type=text style="width:40px"; onchange="SetValue('titleFontSize',this.value,true)">pt&nbsp;&nbsp;粗体<input  id="chk_titleFontBold"type=checkbox onclick="SetValue('titleFontBold',this.checked,false)" checked=true></td>
							</tr>
						</table>
					</td>
				</tr>
			</table>
		</fieldset>
	</div>
	<div id="tab2">
		<table width=100%>
			<tr>
				<td width=50%>
					<table>
						<tr>
							<td>文字颜色</td>
							<td><table width=40 height=20  id="bodyColorPreview"  style="BORDER-RIGHT: white thin groove; BORDER-TOP: buttonshadow thin groove; BORDER-LEFT: buttonshadow thin groove; BORDER-BOTTOM: white thin groove" ><tr><td></td></tr></table></td>
							<td><input type=button value="..." onclick="getSystemColor();SetValue('bodyColor',currentSelectColor,true)" colorDialog=true></td>
						</tr>
					</table>
				</td>
				<td width=50%>
					<table>
						<tr>
							<td>边框颜色</td>
							<td><table width=40 height=20  id="bodyOutBorderColorPreview" style="BORDER-RIGHT: white thin groove; BORDER-TOP: buttonshadow thin groove; BORDER-LEFT: buttonshadow thin groove; BORDER-BOTTOM: white thin groove" ID="Table2"><tr><td></td></tr></table></td>
							<td><input type=button value="..." onclick="getSystemColor();SetValue('bodyOutBorderColor',currentSelectColor,true)" colorDialog=true></td>
						</tr>
					</table>
				</td>
			</tr>
			<tr>
				<td colspan=2>
					<fieldset>
						<legend><font size=2>列头设置</font></legend>
							<input type=checkbox id="chk_AlwaysPrintHead" checked=false onclick="SetValue('AlwaysPrintHead',this.checked,false)"><label for="chk_AlwaysPrintHead">在每一页都打印列头</label><br>
							列头水平对齐方式<select id="AlignList" onchange="SetValue('HeadAlign',this.options[this.selectedIndex].value,true)"><option selected=true value="left">居左</option><option value="center">居中</option><option value="right">居右</option></select>
					</fieldset>
				</td>
			</tr>
		</table>
	</div>
	<div id="tab3">
		<fieldset>
			<legend><font size=2>数据读取间隔时间</font></legend>
			<input type=text id="printInterval" onchange="SetValue('DataReadInterval',this.value,false)"><font size=2>秒<br>
			此参数的值越大，则读取一页数据的时间间隔就越长，若主页面的响应速度比较慢，此时可增加数据读取的成功率。但若主页面的响应速度很快时，则将值设为较小可提高打印或预览速度。</font>
		</fieldset>
		<fieldset>
			<legend>数据读取重试次数</legend>
			<input type=text id="RetryTimesCount" onchange="SetValue('RetryTimesCount',this.value,false)"><font size=2>次<br>
			在指定的数据读取间隔时间内不能成功读取数据时的重试次数，若主页面的响应速度比较慢，将此参数设为较大值可增加数据读取的成功率。</font>
		</fieldset>
	</div>
</div>
</body>
</html>
